package com.example.file_explorer.controller;

import com.example.file_explorer.result.Result;
import com.example.file_explorer.service.Search;
import com.example.file_explorer.vo.FileVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    public Search search;

    @GetMapping("/list")
    public Result<Object> list(String fileName, String path) {
        Set<FileVo> fileNodes = search.find(path, fileName);
        return Result.success(fileNodes);
    }
}
